<?php

  $WorkTable = &$_SQL_TABLE[$GlobPart];

  $TabFields['com'] = getFieldNamesWithLangs($WorkTable, array('title'));
  $TabFields['cat'] = getFieldNamesWithLangs($_SQL_TABLE['category'], array('title'));

  $CategoriesSelect = array_kv(getTableAsArray($_SQL_TABLE['category'], $TabFields['cat']['title'], array(), '', 'id,'.$TabFields['cat']['title']), $TabFields['cat']['title'], 'id');

  if($_REQUEST['mode'] == $GlobPart)
  {  	$PageTitle = '$language["admin"]["companies"]." :: ".$Item["'.$TabFields['com']['title'].'"];';  }
  else
  {  	$PageTitle = '$language["admin"]["companies"];';
  	$AloneMode = $GlobPart;

  	$Query['FromTables'] = 	$WorkTable." com
  							LEFT JOIN ".$_SQL_TABLE['category']." cat ON cat.id = com.category";
  	$Query['Fields'] = "com.*, cat.".$TabFields['cat']['title']." AS category";
  	$Query['TabOrder'] = "com.";
  	$Query['Where'] = "";
  	$Query['GroupBy'] = "";

    $EnableFilter = true;

  	$listInfo['where']['category'] = array(
  								'simple' => 'y',
  								'SQLField' => "com.category = '".$_REQUEST['category']."'",
  								'type' => 'select',
  								'title' => $language['admin']['categories'],
  								'values' => array('' => ucfirst($language['admin']['all'])) + $CategoriesSelect,
  								'JSact' => '',
   								);

    require_once __CFG_PATH_CODE_ADMIN."admin.filter.inc";  }

  $ConfLangArr = array(
                'title_' => array(
                                'type' => 'input',
                                'title' => $language['admin']['title'],
                                'useInAddForm' => 'y',
                                'addVariable' => $_POST,
                                'useInList' => $CONFIG['useInListSort'],
                                'required' => $CONFIG['AdminReqPatAll'],
                                'makeSameValue' => 'linkname',
                                'makeSameValueFrom' => 'title_de',
                                'makeSameValueFunc' => 'makeLinkName(this.value.toLowerCase())',
                                'maxlength' => '100',
                                ),

                'description_' => array(
                                'type' => 'fckeditor',
                                'title' => $language['admin']['description'],
                                'useInAddForm' => 'y',
                                'addVariable' => $_POST,
                                'SmartyMods' => array('unescape'),
                                ),

                'body_' => array(
                                'type' => 'fckeditor',
                                'title' => $language['admin']['text'],
                                'useInAddForm' => 'y',
                                'addVariable' => $_POST,
                                'SmartyMods' => array('unescape'),
                                ),

                );

  $LinkName = make_linkname($_POST['linkname']);

  $GeneratedLangArr = getAdminConfigArrayWithLangs($ConfLangArr, $SITE_LANGS);

  $_SQL_TABLE_FIELDS[$GlobPart] = $GeneratedLangArr + array(


                'ftp_image_logo' => array(
                                'type' => 'image',
                                'old_filename' => $RowItem['linkname'],
                                'filetype' => $CONFIG['imFileType'],
                                'filename' => $LinkName,
                                'filenamePrefix' => $CONFIG['imLogoDefix'],
                                'old_dirname' => __CFG_PATH_IMAGES_URL.$CONFIG['LogoImageFolder'],
                                'dirname' => __CFG_PATH_IMAGES_URL.$CONFIG['LogoImageFolder'],
                                'docroot_dirname' => __CFG_PATH_IMAGES_URL.$CONFIG['LogoImageFolder'],
                                'title' => $language['admin']['logoImage']." (".$CONFIG['CompanyLogoImageSize'].")",
                                'useInAddForm' => 'y',
                                'notUsedInDB' => 'y',
                                'noResize' => 'y',
                                'size' => $CONFIG['CompanyLogoImageSize'],
                                'useFTP' => 'y',
                                //'remoteServerLink' => $CONFIG['FTPImageServerURL'],
                                'ftpServer' => __CFG_PTF_HOSTNAME,
								'ftpUserName' => __CFG_PTF_USERNAME,
								'ftpPassword' => __CFG_PTF_PASSWORD,
								'ftpRootPath' => __CFG_PTF_CORE_PATH,
								),

                'linkname' => array(
								'type' => 'input',
								'title' => $language['admin']['linkName'],
								'addVariable' => $LinkName,
								'useInAddForm' => 'y',
								'unique' => 'y',
								'useInList' => $CONFIG['useInListSort'],
								'useInListEdit' => 'y',
								'required' => $CONFIG['AdminReqPatLinkName'],
								'textUnderField' => '<span class="red">'.$language['admin']['latinAlphAttention'].'</span>',
								'maxlength' => '100',
								),

               /* 'keywords' => array(
                                'type' => 'textarea',
                                'title' => $language['admin']['metaKeywords'],
                                'cols' => '30',
                                'rows' => '6',
                                'addVariable' => $_POST['keywords'],
                                'required' => $CONFIG['AdminReqPatAll'],
                                'useInList' => $CONFIG['useInListSort'],
                                'useInListEdit' => 'y',
                                'useInAddForm' => 'y',
                                ), */

                'phone' => array(
								'type' => 'input',
								'title' => $language['admin']['phone'],
								'addVariable' => $_POST['phone'],
								'useInAddForm' => 'y',
								'useInList' => $CONFIG['useInListSort'],
								'useInListEdit' => 'y',
								'required' => $CONFIG['AdminReqPatAll'],
								'maxlength' => '100',
								),

                'fax' => array(
								'type' => 'input',
								'title' => $language['admin']['fax'],
								'addVariable' => $_POST['fax'],
								'useInAddForm' => 'y',
								'useInList' => $CONFIG['useInListSort'],
								'useInListEdit' => 'y',
								'required' => $CONFIG['AdminReqPatAll'],
								'maxlength' => '100',
								),

                /*'address' => array(
								'type' => 'input',
								'title' => $language['admin']['address'],
								'addVariable' => $_POST['address'],
								'useInAddForm' => 'y',
								'useInList' => $CONFIG['useInListSort'],
								'useInListEdit' => 'y',
								'required' => $CONFIG['AdminReqPatAll'],
								'maxlength' => '100',
								),  */

                'url' => array(
								'type' => 'input',
								'title' => $language['admin']['site'],
								'addVariable' => $_POST['url'],
								'useInAddForm' => 'y',
								'useInList' => $CONFIG['useInListSort'],
								'useInListEdit' => 'y',
								'required' => $CONFIG['AdminReqPatLinkName'],
								'maxlength' => '100',
								),

                'email' => array(
								'type' => 'input',
								'title' => $language['admin']['email'],
								'addVariable' => $_POST['email'],
								'useInAddForm' => 'y',
								'useInList' => $CONFIG['useInListSort'],
								'useInListEdit' => 'y',
								'required' => $CONFIG['emailPattern'],
								'maxlength' => '100',
								),

                /*'work_time' => array(
								'type' => 'input',
								'title' => $language['admin']['work_time'],
								'addVariable' => $_POST['work_time'],
								'useInAddForm' => 'y',
								'useInList' => $CONFIG['useInListSort'],
								'useInListEdit' => 'y',
								'required' => $CONFIG['AdminReqPatAll'],
								'maxlength' => '100',
								), */

                'active' => array(
                                'type' => 'select_link',
                                'title' => $language['admin']['status'],
                                'formid' => $CONFIG['activeFormName'],
                                'addVariable' => 'n',
                                'noUseInEdit' => 'y',
                                'useInList' => $CONFIG['useInListSort'],
                                'inListEdit' => 'select_link',
                                'values' => array(
                                            'y' => array(
                                                    'title' => $language['admin']['active'],
                                                    'className' => 'active',
                                                    'formFields' => array(
                                                                    'act' => 'status',
                                                                    'varvalue' => 'n',
                                                                    'varname' => 'active',
                                                                    getKeyVarName() => '{$Item.$WorkTableKeyFieldName}',
                                                    ),
                                            ),
                                            'n' => array(
                                                    'title' => $language['admin']['inactive'],
                                                    'className' => 'inactive',
                                                    'formFields' => array(
                                                                    'act' => 'status',
                                                                    'varvalue' => 'y',
                                                                    'varname' => 'active',
                                                                    getKeyVarName() => '{$Item.$WorkTableKeyFieldName}',
                                                    ),
                                            ),
                                ),
                ),

                'date' => array(
                                'type' => 'value',
                                'title' => $language['admin']['date'],
                                'addVariable' => 'NOW()',
                                'addVarType' => $CONFIG['VarTypeSQLFunction'],
                                'useInList' => $CONFIG['useInListSort'],
                                'useInListEdit' => 'y',
                                ),

  );


  $_SQL_TABLE_EDIT_FORMS[$GlobPart] = array('active');



?>
